{% extends 'steed_admin/navbar_demo.html' %}

{% block title %}
    <title>确认删除</title>
{% endblock %}

{% load tags %}
{% block main %}
    {% get_meta admin_obj.model as meta %}
    {# 路径导航 #}
    <ol class="breadcrumb">
        <li><a href="{% url 'steed_admin:app_index' %}">Home</a></li>
        <li>{{ meta.app_label }}</li>
        <li><a href="{% url 'steed_admin:table_index' meta.app_label meta.model_name %}">{{ meta.verbose_name_plural }}</a></li>
        {% if request.resolver_match.url_name == 'table_delete' %}
        <li><a href="{% url 'steed_admin:table_change' meta.app_label meta.model_name objs.0.id %}">{{ objs.0 }}</a></li>
        <li class="active">确认删除</li>
        {% endif %}
        {% if request.resolver_match.url_name == 'table_index' %}
        <li class="active">批量删除</li>
        {% endif %}
    </ol>
    {# 页头 #}
    <div class="page-header">
        <h1>确认删除 <small>{{ meta.verbose_name }}</small> ?</h1>
    </div>
    {# 确认信息 #}
    <div class="alert alert-danger" role="alert">下列所有相关的项目都将被删除，记录前有_标记的，是多对多关联</div>
    {% related_objs_lookup objs %}
    {% if request.resolver_match.view_name == 'steed_admin:table_index' %}
        {% url 'steed_admin:table_delete_objs' meta.app_label meta.model_name as action_url %}
    {% endif %}
    <form method="post" action="{{ action_url }}">
        {% csrf_token %}
        {% if request.resolver_match.view_name == 'steed_admin:table_index' %}
            <div hidden>
                {% for obj in objs %}<input name="del_ids" value="{{ obj.id }}">{% endfor %}
            </div>
        {% endif %}
        <button type="submit" class="btn btn-danger">确认删除</button>
        &emsp;
        <a href="#" class="btn btn-default" id="cancel-link">放弃，返回</a>
    </form>
{% endblock %}

{% block js %}
<script>
    $(function () {
        // 把按钮“放弃，返回”的href设置成导航栏最后一个链接一样
        $('a#cancel-link').attr('href', $('ol.breadcrumb>li>a:last').attr('href'))
    })
</script>
{% endblock %}


